package ru.study.thinkin.chapter12;

class MyException2 extends Exception {
	private int x;
	public MyException2() {} 
	public MyException2(String s) {		
		super(s);
	}
	public MyException2(String s,int x) {
		super(s);
		this.x=x;
	}
	public int getVal() {
		return x;
	}
	public String getMessage() {
		return "Подробное сообщение "+x+" "+super.getMessage();
	}
}


public class ExtraFeatures {
	public static void f() throws MyException2 {
		System.out.println("MyException2 в f()");
		throw new MyException2();
	}
	public static void g() throws MyException2 {
		System.out.println("MyException2 в g()");
		throw new MyException2("вызвано в g()");
	}
	public static void h() throws MyException2 {
		System.out.println("MyException2 в h()");
		throw new MyException2("вызвано в h()",47);
	}	
	
	public static void main(String[] args) throws MyException2 {
		try {
			f();
		} catch (Exception e) {
			e.printStackTrace();			
		}
		try {
			g();
		} catch (MyException2 e) {
			e.printStackTrace(System.out);			
		}
		try {
			h();
		} catch (MyException2 e) {
			e.printStackTrace(System.out);
			System.out.println("e.getVal() = "+e.getVal());
		}
	}
}
